//
// Created by guoshunw on 3/19/2021.
//

#include "IntVec.h"

IntVec::IntVec() = default;

IntVec::IntVec(size_t size) : _size(size), _data(new int[_size]) {
    logM("Constructor");
}

IntVec::~IntVec() {
    logM("Destructor");
    delete[] _data;
    _data = nullptr;
}

IntVec::IntVec(const IntVec &other) : _size(other._size) {
    logM("Copy constructor");
    if (0 == _size ) {
        _data = nullptr;
        return;
    }
    _data = new int[_size];
    for(size_t i=0; i<_size; ++i){
        _data[i] = other._data[i];
    }
}

IntVec &IntVec::operator=(const IntVec &other) {
    logM("Copy assignment operator");
    IntVec tmp(other);
    std::swap(_size, tmp._size);
    std::swap(_data, tmp._data);
    return *this;
}

//IntVec &IntVec::operator=(IntVec &&other) noexcept {
//    logM("Move assignment operator");
//    std::swap(_size, other._size);
//    std::swap(_data, other._data);
//    return *this;
//}

